package com.qdhh.enrollment.controller.miniapp;

import com.qdhh.enrollment.dto.MilestoneDTO;
import com.qdhh.enrollment.service.MilestoneService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/miniapp/milestones")
@RequiredArgsConstructor
public class MiniappMilestoneController {

    private final MilestoneService milestoneService;

    @GetMapping
    public Map<String, Object> list(@RequestParam(value = "type", required = false) String type,
                                    @RequestParam(value = "limit", required = false) Integer limit) {
        List<MilestoneDTO> data = milestoneService.list(type, limit);
        Map<String, Object> resp = new HashMap<>();
        resp.put("code", 200);
        resp.put("message", "OK");
        resp.put("data", data);
        return resp;
    }
}

